package cc.bable.nexus.entity;

import act.db.morphia.MorphiaAdaptiveRecord;
import act.util.SimpleBean;
import act.validation.Email;
import act.validation.NotBlank;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Property;
import org.mongodb.morphia.annotations.Transient;

import java.util.List;


/**
 * @author Genkō Lee
 */
@Entity("admin")
public class Admin extends MorphiaAdaptiveRecord<Admin> implements SimpleBean {

    public static final String KEY = "entity.admin";

    /**
     * 帐号
     */
    @Property("login_name")
    public String loginName;

    /**
     * 明文密码
     */
    @Transient
    public String plainPassword;

    /**
     * 密码
     */
    public String password;

    /**
     * 盐值
     */
    public String salt;

    /**
     * 真实姓名
     */
    @NotBlank(message = "valid.name.notblank")
    public String name;

    /**
     * 状态
     */
    public String state;

    /**
     * 邮箱
     */
    @Email(message = "valid.email")
    public String email;

    /**
     * 手机
     */
    public String mobile;

    /**
     * 电话
     */
    public String phone;

    /**
     * 角色 Id
     */
    @Property("role_ids")
    public List<ObjectId> roleIds;


    // Constructor
    public Admin() {
    }

    public Admin(String name) {
        this.loginName = name;
    }

} // end class
